﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Net;
using Microsoft.Win32;

namespace 软件自动更新
{
    /// <summary>
    /// 软件的更新类
    /// </summary>
    public class SystemUpdate
    {
        public SystemUpdate()
        {
            ServerPort = 13141;
            KeyToken = Guid.Empty;
        }
        /// <summary>
        /// 软件名称
        /// </summary>
        public string SoftName { get; set; }
        /// <summary>
        /// 软件的头描述
        /// </summary>
        public string SoftNameHead { get; set; }
        /// <summary>
        /// 软件的服务器地址
        /// </summary>
        public string ServerIp { get; set; }
        /// <summary>
        /// 服务器的更新端口号，默认为13141
        /// </summary>
        public int ServerPort { get; set; }
        /// <summary>
        /// 用于通信验证的网络令牌
        /// </summary>
        public Guid KeyToken { get; set; }

        public static SystemUpdate FileNetServer = new SystemUpdate()
        {
            SoftName = "LCL.FileNetServer",
            SoftNameHead = "FileNetServer",
            ServerIp = GetIP(),
            ServerPort = 18468,
        };
        public static SystemUpdate PushNetServer = new SystemUpdate()
        {
            SoftName = "LCL.PushNetServer",
            SoftNameHead = "PushNetServer",
            ServerIp = GetIP(),
            ServerPort = 18468,
        };
        public static SystemUpdate Codematic = new SystemUpdate()
        {
            SoftName = "LCL.Tools",
            SoftNameHead = "Codematic",
            ServerIp = GetIP(),
            ServerPort = 18468,
        };
        public static SystemUpdate Demo项目 = new SystemUpdate()
        {
            SoftName = "LCL.NetworkDemo",
            SoftNameHead = "NetworkDemo",
            ServerIp = GetIP(),
            ServerPort = 18468,
        };
        public static string GetIP()
        {
            string result = "127.0.0.1";
            string hostName = Dns.GetHostName();
            IPHostEntry localhost = Dns.GetHostByName(hostName);
            IPAddress localaddr = localhost.AddressList[0];
            result = localaddr.ToString();
            return result;
        }
    }

    public class Class1
    {
        public static SystemUpdate CurrentSystem = SystemUpdate.Demo项目;
    }



}
